package com.lieve.tomcat;

/**
 * @author sunlijiang
 * @date 2020/4/2
 */
public class InheritableThreadLocalTest {

    private static java.lang.InheritableThreadLocal inheritableThreadLocal = new java.lang.InheritableThreadLocal();
    private static ThreadLocal threadLocal = new ThreadLocal();
    public static void main(String[] args) {
        threadLocal.set("Hello");
        inheritableThreadLocal.set("World");
        System.out.println(Thread.currentThread().getName() + " " + threadLocal.get());
        System.out.println(Thread.currentThread().getName() + " " + inheritableThreadLocal.get());
        Thread1 thread = new Thread1();
        thread.start();
    }

    static class Thread1 extends Thread {
        @Override
        public void run() {
            super.run();
            System.out.println(threadLocal.get());
            System.out.println(inheritableThreadLocal.get());
        }
    }
}
